package cn.cxy.demo

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import kotlinx.android.synthetic.main.activity_main.*
import java.util.*

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        initRecyclerView()
    }

    private fun initRecyclerView() {
        val adapter = RvAdapter()
        adapter.setData(getData())
        recyclerView.adapter = adapter
        recyclerView.layoutManager = LinearLayoutManager(this)
    }

    private fun getData(): List<ChatBean> {
        val dataList = ArrayList<ChatBean>()
        dataList.add(ChatBean(R.drawable.img1, "黄沙地产1", "今天吧", "晚上10:20"))
        dataList.add(ChatBean(R.drawable.img2, "黄沙地产2", "这周去看房，怎么样？", "晚上10:21"))
        dataList.add(ChatBean(R.drawable.img3, "黄沙地产3", "不能啦", "晚上10:22"))
        dataList.add(ChatBean(R.drawable.img4, "黄沙地产4", "别调皮，要乖", "晚上10:23"))
        dataList.add(ChatBean(R.drawable.img5, "黄沙地产5", "你真是的", "晚上11:24"))
        dataList.add(ChatBean(R.drawable.img6, "黄沙地产6", "没什么大不了", "晚上11:25"))
        dataList.add(ChatBean(R.drawable.img7, "黄沙地产7", "乖乖睡吧", "晚上11:26"))
        dataList.add(ChatBean(R.drawable.img8, "黄沙地产8", "明天老地方见", "晚上11:27"))
        dataList.add(ChatBean(R.drawable.img9, "黄沙地产9", "好想某个人啊", "晚上11:28"))
        dataList.add(ChatBean(R.drawable.img10, "黄沙地产10", "最好还是注意点好", "晚上11:29"))
        dataList.add(ChatBean(R.drawable.img11, "黄沙地产11", "今天就这样吧", "晚上11:30"))

        return dataList
    }
}